#include "stdafx.h"

namespace ui
{
	void ComboListElement::Init()
	{
		assert(!m_bInternInited);
		if (m_bInternInited)
			return;
		m_bInternInited = true;

		m_pCheck = static_cast<CheckBox*>(FindSubControl(L"check"));
		m_pImage = static_cast<Control*>(FindSubControl(L"image"));
		m_pLabel = static_cast<Label*>(FindSubControl(L"label"));

		if (m_pListWnd)
		{
			m_pCheck->SetVisible(m_pListWnd->IsMutilSelMode());
			//m_pImage->SetVisible(m_pListWnd->IsImageMode());
		}

		m_pCheck->AttachSelect(nbase::Bind([this](ui::EventArgs *args){
			//m_pLis
			return true;
		}, std::placeholders::_1));

		m_pLabel->SetText(m_sText);

		SetImage(m_sImg);
	}

	void ComboListElement::SetText(const std::wstring& strText){
		m_sText = strText;
		if (m_pLabel){
			m_pLabel->SetText(strText);
		}	
	}
	std::wstring ComboListElement::GetText() const{
		std::wstring s = m_sText;
		if (m_pLabel)
			s = m_pLabel->GetText();;
		return s;
	}

	void ComboListElement::SetImage(std::wstring sImg)
	{
		if (m_pImage){
			m_pImage->SetVisible(!sImg.empty());
			m_pImage->SetBkImage(sImg);
			m_sImg = L"";
		}
		else
			m_sImg = sImg;
	}
} // namespace ui

